import SwiftUI

struct ExploreView: View {
    @State private var searchText = ""
    
    var body: some View {
        NavigationView {
            ScrollView {
                LazyVStack(spacing: 16) {
                    // 热门修炼方案
                    VStack(alignment: .leading, spacing: 12) {
                        Text("热门修炼方案")
                            .font(.headline)
                        
                        ScrollView(.horizontal, showsIndicators: false) {
                            HStack(spacing: 12) {
                                ForEach(0..<5) { _ in
                                    VStack(alignment: .leading) {
                                        RoundedRectangle(cornerRadius: 12)
                                            .fill(Color.blue.opacity(0.1))
                                            .frame(width: 200, height: 120)
                                            .overlay(
                                                Image(systemName: "flame.fill")
                                                    .foregroundColor(.blue)
                                            )
                                        
                                        Text("基础剑法修炼")
                                            .font(.system(size: 16, weight: .medium))
                                        Text("适合初学者的入门计划")
                                            .font(.subheadline)
                                            .foregroundColor(.secondary)
                                    }
                                    .frame(width: 200)
                                }
                            }
                            .padding(.horizontal)
                        }
                    }
                    .padding(.top)
                    
                    // 修炼社区
                    VStack(alignment: .leading, spacing: 12) {
                        Text("修炼社区")
                            .font(.headline)
                        
                        ForEach(0..<5) { _ in
                            VStack(alignment: .leading, spacing: 8) {
                                HStack {
                                    Circle()
                                        .fill(Color.blue)
                                        .frame(width: 40, height: 40)
                                        .overlay(
                                            Image(systemName: "person.fill")
                                                .foregroundColor(.white)
                                        )
                                    
                                    VStack(alignment: .leading) {
                                        Text("修炼者")
                                            .font(.system(size: 16, weight: .medium))
                                        Text("2小时前")
                                            .font(.caption)
                                            .foregroundColor(.secondary)
                                    }
                                    
                                    Spacer()
                                }
                                
                                Text("分享今日修炼心得：在晨练中发现新的突破点，感觉气息运行更加顺畅...")
                                    .lineLimit(3)
                                
                                HStack {
                                    Image(systemName: "heart")
                                    Text("128")
                                    
                                    Image(systemName: "message")
                                        .padding(.leading)
                                    Text("32")
                                    
                                    Spacer()
                                }
                                .foregroundColor(.secondary)
                            }
                            .padding()
                            .background(Color(.systemBackground))
                            .cornerRadius(12)
                        }
                    }
                }
                .padding()
            }
            .background(Color(.systemGroupedBackground))
            .navigationTitle("发现")
            .searchable(text: $searchText, prompt: "搜索修炼方案、心得")
        }
    }
}

